export default defineEventHandler(async (event) => {
  const query = getQuery(event);
  const { city, location } = query;
  
  // 模拟延迟
  await new Promise(resolve => setTimeout(resolve, 500));
  
  try {
    // 模拟天气数据
    const mockWeatherData = {
      success: true,
      data: {
        city: city || '广州市',
        adcode: '440100',
        province: '广东省',
        reporttime: new Date().toISOString(),
        casts: [
          {
            date: new Date().toISOString().split('T')[0],
            week: '1',
            dayweather: '晴',
            nightweather: '多云',
            daytemp: '28',
            nighttemp: '22',
            daywind: '东南风',
            nightwind: '东南风',
            daypower: '3',
            nightpower: '3'
          },
          {
            date: new Date(Date.now() + 86400000).toISOString().split('T')[0],
            week: '2',
            dayweather: '多云',
            nightweather: '小雨',
            daytemp: '26',
            nighttemp: '20',
            daywind: '东风',
            nightwind: '东风',
            daypower: '2',
            nightpower: '2'
          },
          {
            date: new Date(Date.now() + 172800000).toISOString().split('T')[0],
            week: '3',
            dayweather: '小雨',
            nightweather: '阴',
            daytemp: '24',
            nighttemp: '18',
            daywind: '北风',
            nightwind: '北风',
            daypower: '4',
            nightpower: '4'
          },
          {
            date: new Date(Date.now() + 259200000).toISOString().split('T')[0],
            week: '4',
            dayweather: '阴',
            nightweather: '多云',
            daytemp: '25',
            nighttemp: '19',
            daywind: '东北风',
            nightwind: '东北风',
            daypower: '3',
            nightpower: '3'
          }
        ],
        lives: [
          {
            province: '广东省',
            city: city || '广州市',
            adcode: '440100',
            weather: '晴',
            temperature: '26',
            winddirection: '东南风',
            windpower: '3',
            humidity: '65',
            reporttime: new Date().toISOString()
          }
        ]
      },
      message: '获取天气信息成功'
    };
    
    return mockWeatherData;
  } catch (error) {
    console.error('天气API模拟数据生成失败:', error);
    throw createError({
      statusCode: 500,
      statusMessage: '获取天气信息失败'
    });
  }
}); 